Geotransforms

May-June, 2018, Mauro Alberti, alberti.m65@gmail.com

1. Examples


In [26]:
from pygsf.spatial.rasters.geotransform import *

In [27]:
gt1 = GeoTransform(1500, 3000, 10, 10)

In [28]:
gt1


Out[28]:
GeoTransform(topLeftX: 1500.00, topLeftY: 3000.00, pixWidth: 10.00, pixHeight: -10.00, rotRow: 0.00, rotColumn: 0.00)

Forward and backward transformation examples


In [29]:
ijPixToxyGeogr(gt1, 0, 0)


Out[29]:
(1500.0, 3000.0)

In [30]:
xyGeogrToijPix(gt1, 1500, 3000)


Out[30]:
(0.0, 0.0)

In [31]:
ijPixToxyGeogr(gt1, 1, 1)


Out[31]:
(1510.0, 2990.0)

In [32]:
xyGeogrToijPix(gt1, 1510, 2990)


Out[32]:
(1.0, 1.0)

In [33]:
ijPixToxyGeogr(gt1, 10, 10)


Out[33]:
(1600.0, 2900.0)

In [34]:
xyGeogrToijPix(gt1, 1600, 3100)


Out[34]:
(-10.0, 10.0)

calculating the X, Y geographic coordinate arrays


In [35]:
X, Y = gtToxyCellCenters(
    gt=gt1,
    num_rows=10,
    num_cols=5)

In [36]:
print(X)


[[1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]]

In [37]:
print(Y)


[[2995. 2995. 2995. 2995. 2995.]
 [2985. 2985. 2985. 2985. 2985.]
 [2975. 2975. 2975. 2975. 2975.]
 [2965. 2965. 2965. 2965. 2965.]
 [2955. 2955. 2955. 2955. 2955.]
 [2945. 2945. 2945. 2945. 2945.]
 [2935. 2935. 2935. 2935. 2935.]
 [2925. 2925. 2925. 2925. 2925.]
 [2915. 2915. 2915. 2915. 2915.]
 [2905. 2905. 2905. 2905. 2905.]]